package qa.tests;

import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.model.Build;
import org.apache.maven.plugin.testing.stubs.ArtifactStub;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.PlexusTestCase;

public class AssertCounterProjectStub extends MavenProjectStub {
    private Build build;

    public MavenProject getExecutionProject() {
        return this;
    }

    public Build getBuild() {
        if (build == null) {
            build = new Build();

            build.setDirectory(PlexusTestCase.getBasedir() + "/target/test-harness/weave");
            build.setOutputDirectory(PlexusTestCase.getBasedir() + "/target/test-harness/weave/classes");
        }

        return build;
    }

    public Artifact getArtifact() {
        return new ArtifactStub();
    }

    public List getCompileSourceRoots() {
        return Collections.singletonList(PlexusTestCase.getBasedir() + "/src/test/sources");
    }
    @Override
    public List getTestClasspathElements() throws DependencyResolutionRequiredException {
        return Arrays.asList(path("target/test-classes"), path("target/classes"));
    }

    private String path(String file) {
        return new File(file).getAbsolutePath();
    }
}
